#include <string>
#include <sstream>

#include "node_element.h"

using namespace std;

NodeElement::NodeElement (const string & aRefElement, Multiplicity & aMult) : multiplicity (aMult), refElement (aRefElement) {
}

NodeElement::~NodeElement () {
}

string NodeElement::getName() {
	//TODO
}

string NodeElement::generateRegex(DoctypeDefinition* dtd) {
	BaseElement* e = dtd->getElementByName(refElement);
	string regex = "(" + e->generateRegex(dtd) + ")";
	regex += "{"+intToString(multiplicity.min)+","+intToString(multiplicity.max)+"}";
	
	return regex;
}

string NodeElement::intToString(unsigned int number) {
	ostringstream ostr; //output string stream
    ostr << number; //use the string stream just like cout,
    //except the stream prints not to stdout but to a string.

    return ostr.str();
}

void NodeElement::print(std::ostream& out) {
	out << refElement;
	multiplicity.print(out);
}

